//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.qy137.service.impl;

import com.qy137.entity.Article;
import com.qy137.vo.ArticleVo;
import java.time.LocalDateTime;
import org.apache.commons.lang.StringUtils;
import org.qy137.dao.ArticleDao;
import org.qy137.service.ArticleService;
import org.qy137.utils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleDao articleDao;

    public ArticleServiceImpl() {
    }

    public CommonResult getArticleByNavId(String navId) {
        Article article = (Article)this.articleDao.selectById(navId);
        return article != null ? new CommonResult(2000, "查询成功", article) : new CommonResult(5000, "查询失败", article);
    }

    public CommonResult updateArticleByNavId(ArticleVo articleVo) {
        Article article = new Article();
        article.setId(articleVo.getId());
        article.setGmtModified(LocalDateTime.now());
        if (StringUtils.isNotEmpty(articleVo.getArtTitle())) {
            article.setArtTitle(articleVo.getArtTitle());
        }

        if (StringUtils.isNotEmpty(articleVo.getArtPic())) {
            article.setArtPic(articleVo.getArtPic());
        }

        if (StringUtils.isNotEmpty(articleVo.getArtDesc())) {
            article.setArtDesc(articleVo.getArtDesc());
        }

        int i = this.articleDao.updateById(article);
        return i > 0 ? new CommonResult(2000, "修改成功", (Object)null) : new CommonResult(5000, "修改失败", (Object)null);
    }
}
